#include "widget_background_parent.h"

widget_background_parent::widget_background_parent(QWidget *parent) : QWidget(parent)
{
    //设定背景默认颜色
    color = QColor(212,241,249);
}

void widget_background_parent::set_color(QColor color)
{
    this->color = color;
}

void widget_background_parent::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    
    //创建QPainter
    QPainter paitner(this);
    
    //启用抗锯齿
    paitner.setRenderHint(QPainter::Antialiasing);
    
    //设置画笔颜色和宽度
    QPen pen;
    pen.setColor(QColor(111,179,184));   //设置边框颜色
    pen.setWidth(0);
    paitner.setPen(pen);
    
    //设置笔刷颜色
    QBrush brush;
    brush.setColor(this->color); //设置填充颜色
    brush.setStyle(Qt::SolidPattern);
    paitner.setBrush(brush);
    
    //获取控件的矩形区域
    QRect rect = this->rect();
    
    //绘制角边圆角
    paitner.drawRoundedRect(rect , 12 , 12);
}



